<template>
  <div>
    <h2>用户登录页面</h2>
    <table class="table table-bordered">
      <tr>
        <td>用户名:</td>
        <td>
          <input type="text" v-model="loginData.T_UName">
        </td>
      </tr>

      <tr>
        <td>密码:</td>
        <td>
          <input type="password" v-model="loginData.T_UPwd">
        </td>
      </tr>

      <tr>
        <td></td>
        <td>
          <input type="button" value="登录" @click="login">
        </td>
      </tr>
    </table>
  </div>
</template>

<script setup lang="ts">

import axios from 'axios';
import { reactive,toRefs } from 'vue';
import { useRouter} from 'vue-router'

let router = useRouter()
let data =reactive({
  loginData:{
    T_UName:'',
    T_UPwd:''
  }
})

let {loginData} = toRefs(data)

//登录
const login = ()=>{
  //非空判断
  if(loginData.value.T_UName==""){
    return alert('用户名不能为空')
  }
  if(loginData.value.T_UPwd==""){
    return alert('密码不能为空')
  }
  if(loginData.value.T_UName=="admin" && loginData.value.T_UPwd=="admin"){
      router.push({
        path:'/register',
        query:{
          T_UName:loginData.value.T_UName,
          T_UPwd:loginData.value.T_UPwd
        }
      })
     }
}

</script>

<style scoped>

</style>